﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Benefit.Models.Sys;
namespace Benefit.Interface.Sys
{
    /// <summary>
    /// 交易历史表(需要)
    /// </summary>
    public interface ITradeHistory
    {

        /// <summary>
        /// 判断当前输入的日期是否已经被传输入过数据库ok
        /// </summary>
        /// <param name="pdate"></param>
        /// <returns></returns>
        bool HasChangeIntoDb(string pdate);
        /// <summary>
        /// 获取前一个交易日
        /// </summary>
        /// <param name="tradeHistoryId"></param>
        /// <param name="db"></param>
        /// <returns></returns>
        TradeHistory GetPreviousTradingDay(int tradeHistoryId);
        /// <summary>
        /// 获取上周的最后一个交易日
        /// </summary>
        /// <param name="tradeHistoryId"></param>
        /// <param name="db"></param>
        /// <returns></returns>
        TradeHistory GetPreviousWeekLastTradingDay(int tradeHistoryId);


        /// <summary>
        /// 给没有日期横岗的日期加上横岗
        /// </summary>
        /// <param name="pdate"></param>
        /// <returns></returns>
        string AddHorizontalLineIntoPdate(string pdate);

        /// <summary>
        /// 查询月的最后一个交易日
        /// </summary>
        /// <param name="year"></param>
        /// <param name="month"></param>
        /// <returns></returns>
        TradeHistory GetMonthLastTradingDay(int year, int month);
        /// <summary>
        /// 查询年的最后一个交易日
        /// </summary>
        /// <param name="year"></param>
        /// <param name="month"></param>
        /// <returns></returns>
        TradeHistory GetYearLastTradingDay(int year);
        /// <summary>
        /// 根据日期得到该交易日在分析系统中的插入日期
        /// </summary>
        /// <param name="pdate"></param>
        /// <returns></returns>
        TradeHistory GetSettlementModel(string pdate);

        TradeHistory GetModel(int day, int month, int year);

        /// <summary>
        /// 根据日期得到该交易日在分析系统中的插入日期
        /// </summary>
        /// <param name="pdate"></param>
        /// <returns></returns>
        DateTime GetPdateFromTradeHistoryId(int tradeHistoryId);

        /// <summary>
        /// 根据日期得到该交易日在分析系统中的插入日期
        /// </summary>
        /// <param name="pdate"></param>
        /// <returns></returns>
        string GetPdateFromSettlementId(int tradeHistoryId);

        /// <summary>
        /// 保存导入记录ok
        /// </summary>
        /// <param name="pdate"></param>
        /// <returns></returns>
        int Insert(string pdate);
        /// <summary>
        /// 查询当日为当前年的第几个周
        /// </summary>
        /// <param name="day">查询日期</param>
        /// <param name="WeekStart">1表示 周一至周日 为一周,2表示 周日至周六 为一周</param>
        /// <returns></returns>
        int WeekOfYear(DateTime pdate);
        /// <summary>
        /// 删除当日导入记录
        /// </summary>
        /// <param name="pdate"></param>
        void Delete(string pdate);
        /// <summary>
        /// 得到一个对象
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        TradeHistory GetModel(int id);

        /// <summary>
        /// 得到当前交易日的前五天的交易日期
        /// </summary>
        /// <returns></returns>
        List<TradeHistory> GetFrontFiveDayTradeHistoryIds(int tradeHistoryId);
        /// <summary>
        /// 获取数据到出日的时间ok
        /// </summary>
        /// <param name="tradeHistoryId"></param>
        /// <returns></returns>
        DateTime GetDateTimeFromTradeHistoryId(int tradeHistoryId);
        /// <summary>
        /// 得到某个周的所有的交易日
        /// </summary>
        /// <param name="week"></param>
        /// <param name="month"></param>
        /// <param name="year"></param>
        /// <returns></returns>
        List<TradeHistory> GetWeekTradeingDay(int week, int year);
        /// <summary>
        /// 得到周一共交易了多少天
        /// </summary>
        /// <param name="week"></param>
        /// <param name="year"></param>
        /// <param name="db"></param>
        /// <returns></returns>
        int GetWeekTradeCount(int week, int year);

        /// <summary>
        /// 判断时间是否在时间段
        /// </summary>
        /// <param name="state"></param>
        /// <returns></returns>
        bool TimeInState(int state, int pdate);
        /// <summary>
        /// 得到最后一个交易日的结算编号
        /// </summary>
        /// <returns></returns>
        int GetLastTradeHistoryId();

        /// <summary>
        /// 得到最后一个交易日的无分割线日期字符串
        /// </summary>
        /// <returns></returns>
        string GetLastTradeHistoryDateString();

        /// <summary>
        /// 得到某个月的所有的交易日
        /// </summary>
        /// <param name="week"></param>
        /// <param name="month"></param>
        /// <param name="year"></param>
        /// <returns></returns>
        List<TradeHistory> GetMonthTradeingDay(int month, int year);
        /// <summary>
        /// 得到某年的所有的交易日
        /// </summary>
        /// <param name="week"></param>
        /// <param name="month"></param>
        /// <param name="year"></param>
        /// <returns></returns>
        List<TradeHistory> GetYearTradeingDay(int month, int year);

        /// <summary>
        /// 得到查询时间的前一个月的第一天
        /// </summary>
        /// <param name="month"></param>
        /// <param name="year"></param>
        /// <returns></returns>
        DateTime GetLastMonth(int month, int year);
        /// <summary>
        /// 查找周最后一个交易日
        /// </summary>
        /// <param name="week"></param>
        /// <param name="year"></param>
        /// <param name="db"></param>
        /// <returns></returns>
        TradeHistory GetWeekLastTradingDay(int week, int year);
        /// <summary>
        /// 查找周第一个交易日
        /// </summary>
        /// <param name="week"></param>
        /// <param name="year"></param>
        /// <param name="db"></param>
        /// <returns></returns>
        TradeHistory GetWeekFirstTradingDay(int week, int year);



        List<TradeHistory> GetList();
    }
}